package com.liyy.platform.other.Provider_Consumer;

import java.util.concurrent.BlockingQueue;

public class Consumer implements Runnable{
	
	private BlockingQueue<Integer> queue;

	public Consumer(BlockingQueue<Integer> queue) {
		this.queue=queue;
	}

	@Override
	public void run() {
		try {
			while(true){
				Thread.sleep(700);
				//获取数据
				int id=queue.take();
				//进行数据处理。休眠1000毫秒模拟耗时
				System.out.println("当前线程:" + Thread.currentThread().getName() + "消费："+id);
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
}
